#include <jni.h>
#include <string>
#include <leaktracer.h>
#include <MemoryTrace.hpp>
//./arm-linux-androideabi-addr2line -e  libleaktracer.so 0x3c0c6 0x3af5c 0x3ae80 0x3a20a
extern "C" JNIEXPORT jstring JNICALL
Java_com_qunar_customleaktracer_MainActivity_stringFromJNI(
        JNIEnv* env,
        jobject /* this */) {
//    leaktracer_startMonitoringAllThreads();
    leaktracer::MemoryTrace::GetInstance().startMonitoringAllThreads();
    std::string hello = "Hello from C++";
    void *leakedMallocMem = malloc(100);
    // 申请内存并释放
    void *safeMallocMem = malloc(100);
    free(safeMallocMem);

    leaktracer::MemoryTrace::GetInstance().stopAllMonitoring();
    leaktracer::MemoryTrace::GetInstance().writeLeaksToFile("/sdcard/leak.out");
    return env->NewStringUTF(hello.c_str());
}